Repository navigation
feat(lock-screen): lock and unlock the screen on Android and iOS simulators - #5057
Conversation
…lators
Add `agent-device lock-screen <lock|unlock>` and
`client.command.lockScreen({ action })`. The action selects one of two
new system-button cells, lockScreen or unlockScreen, the way
hardware-button selects a key, and the result reports the lock state the
owner read back: `{ action: 'lock-screen', state, message }`.
Android locks with KEYCODE_SLEEP and unlocks with KEYCODE_WAKEUP then
`wm dismiss-keyguard`, each verified by the keyguard state
`dumpsys window` reports. A keyguard whose foreground user has a PIN,
pattern, or password is refused before anything is sent, with
`lock-screen-secure`. The keyguard read moves to keyguard.ts, shared
with fold.
The iOS runner locks with XCUIDevice's pressLockButton, checked with
responds(to:), and unlocks with a swipe up from the bottom edge, after
the same button wakes a dark screen; a swipe on a dark screen unlocks
SpringBoard but leaves the screen off. Success
needs SpringBoard's lock state, and for a lock also the lock screen date
view or cover sheet window. The verification window starts after the
dispatch returns and every wait is followed by a read. Unlock also needs
com.apple.springboard.hasBlankedScreen to report the screen on. A
passcode prompt is refused with `lock-screen-secure`.
A screen already in the requested state is left alone. Neither command
activates the session app or settles. Physical iPhones and iPads, Android
TV, tvOS, macOS, and web refuse with UNSUPPORTED_OPERATION.
The system family keeps one module per command, so the new facet adds one module and 15 top-level statements to the client, CLI and command-surface entries. No maintainer has approved the row yet, so its owner is a placeholder.
|
Thanks for the work on lock and unlock. The code at 28e5e1e is ready, and no conflicts are known. The Smoke Tests failure is in live-automation-scenario.ts:101 (the catalog snapshot still showed the Automation lab), a navigation timing route with no lock-screen call, and the Runner Build job reports every step as success, so both look unrelated to this diff. Not blocking, and fine to take or leave: on Android with the screen lock set to None, |
LOCK_SCREEN_STATES sits beside LOCK_SCREEN_ACTIONS, and the result type, the MCP output schema, the session journal and the daemon rows read it instead of repeating 'locked' and 'unlocked'.
With the screen lock set to None, Android shows no keyguard, so lock sent the sleep key and then failed unverified. It now reads the foreground user's lock settings first and refuses with lock-screen-disabled and dispatched: no. On a secure device with "Power button instantly locks" off, the keyguard appears only after lock_screen_lock_after_timeout. Lock now waits that long on top of its 5 s window, 5 s when the setting is unset, up to one minute so the command stays inside the daemon's request envelope.
On a simulator whose screen SpringBoard has blanked while unlocked, the lock button can wake the screen instead of locking it. lockScreen now wakes such a screen first and presses again only if it is still unlocked.
On an Android 16 emulator with a PIN and "Power button instantly locks" off, the keyguard showed about 0.2 s after lock_screen_lock_after_timeout and never sooner than 5 s, even with the setting unset, 0 or 2000. The deferral now has that 5 s floor, so a 0 setting no longer leaves a 5 s window that ends as the keyguard appears.
The lock dispatch's decision moves into dispatchLock(screenIsBlanked:wake: readState:press:) so the runner unit tests drive it: a dark screen is woken and pressed again only while still unlocked, a lit screen is pressed once, and a wake refusal stops before any press.
|
|
Thanks for the follow-up. At e55a5d4 the code looks good, and the notes from the earlier review (#5057 (comment)) are addressed: the refused-lock case, the deferred-keyguard wait, the iOS wake before lock, the help and docs, and the dedupe. No conflicts. Only Body rules is not passing, and it was cancelled rather than failed. It checks PR body and commit metadata, not code this diff changes, and the other 15 checks pass. Before merge, Body rules needs a rerun, and the maintainer needs to decide the |
agent-device 0.21.43 adds the lock-screen command (callstack/agent-device#5057), which device.lock() and device.unlock() need. The mobile engine and the four packages that pin agent-device or its plugins move with it. Refs ENG-1526 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Closes #4798. The iOS side follows the reviewed design of #3001.
agent-device lock-screen <lock|unlock>andclient.command.lockScreen({ action })return{ action: 'lock-screen', state: 'locked' | 'unlocked', message }once the device reports that state. No app is activated and there is no--settle.KEYCODE_SLEEP, orKEYCODE_WAKEUPthenwm dismiss-keyguard, verified byisKeyguardShowing. A screen lock set to None refuseslockwithlock-screen-disabled; a PIN, pattern, or password refusesunlockwithlock-screen-secure. Both send nothing. A deferred keyguard ("Power button instantly locks" off) is awaited forlock_screen_lock_after_timeout, 5–60 s.pressLockButtonafterresponds(to:); unlock swipes up from the bottom edge, back to the app in front. A dark screen is woken first. Success needscom.apple.springboard.lockstate, a lock surface forlock, and a lit screen forunlock. A passcode prompt giveslock-screen-secure.UNSUPPORTED_OPERATION.lock-screennames the surface it shows, likeapp-switcher. Two system-button cells are picked by the positional, as inhardware-button.Before / after
Base has no
lock-screen. Head, Settings in front:Validation
e55a5d4d7:check:affected --run --headpassed format, lint, typecheck, layering, Fallow, build, package, integration-node, and vitest-related;pnpm gatepassed provider-integration, command-docs, capabilities-matrix, xctest-selection, runner-error-codes, and daemon-wire-compat.chore(gates)commit addssystem/lock-screen.tstoAPPROVED_CLOSURE_ADDITIONS, because the system family keeps one module per command. Please approve or reject that row; its owner is a placeholder.